package com.roncoo.ysq.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.roncoo.ysq.entity.HomePrecinct;
import com.roncoo.ysq.dao.HomePrecinctMapper;
import com.roncoo.ysq.service.IHomePrecinctService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yuanshuaiqiang
 * @since 2021-03-23
 */
@Service
public class HomePrecinctServiceImpl extends ServiceImpl<HomePrecinctMapper, HomePrecinct> implements IHomePrecinctService {

    @Resource
    private HomePrecinctMapper homePrecinctMapper;
    @Override
    public IPage<HomePrecinct> findAll(Page page, HomePrecinct homePrecinct) {
        page.setSize(4);
        QueryWrapper<HomePrecinct> queryWrapper = new QueryWrapper<>();
        if (StringUtils.isNotBlank(homePrecinct.getPName())){
            queryWrapper.like("p_name",homePrecinct.getPName());
        }
        if (homePrecinct.getStatus()!=null){
            queryWrapper.eq("status",homePrecinct.getStatus());
        }
        Page page1 = homePrecinctMapper.selectPage(page, queryWrapper);
        return page1;
    }
}
